package com.wzqj.agent.common;

import com.alibaba.fastjson.JSONObject;

/**
 * Created by wanghao@weipass.cn on 2015/8/6.
 */
public class SoaConfig {

    /**
     * 本服务在soa配置的token
     */
    String token = "";
    /**
     * 本服务在soa生成的appCode
     */
    String appCode = "";
    /**
     * 本服务在soa生成的appCode
     */
    String secret = "";
    /**
     * soa服务调用地址
     */
    String center = "";

    private static JSONObject soaParam = null;

    private static SoaConfig instance = null;

    public static JSONObject getSoaParam(){

        if(soaParam == null){
            soaParam = new JSONObject();
            soaParam.put("SOA_CENTER",ConfigHelper.getProperty("SOA_CENTER"));
            soaParam.put("SOA_APP_CODE", ConfigHelper.getProperty("SOA_APP_CODE"));
            soaParam.put("SOA_SECRET", ConfigHelper.getProperty("SOA_SECRET"));
        }
        return soaParam;
    }

    public static SoaConfig getInstance(){

        if(instance == null){
            instance = new SoaConfig();
            instance.setCenter(ConfigHelper.getProperty("SOA_CENTER"));
            instance.setToken(ConfigHelper.getProperty("SOA_TOKEN"));
            instance.setAppCode(ConfigHelper.getProperty("SOA_APP_CODE"));
            instance.setSecret(ConfigHelper.getProperty("SOA_SECRET"));
        }
        return instance;
    }

    public String getToken() {
        return token;
    }

    public void setToken(String token) {
        this.token = token;
    }

    public String getAppCode() {
        return appCode;
    }

    public void setAppCode(String appCode) {
        this.appCode = appCode;
    }

    public String getSecret() {
        return secret;
    }

    public void setSecret(String secret) {
        this.secret = secret;
    }

    public String getCenter() {
        return center;
    }

    public void setCenter(String center) {
        this.center = center;
    }
}
